package com.ad.pet.app.mall.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.ad.pet.R;
import com.ad.pet.common.data.utils.date.DateUtil;
import com.ad.pet.models.remote.mall.OrderDate;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by liuyixiang on 2019/12/3.
 */

public class DayTimeAdapter extends BaseQuickAdapter<OrderDate,BaseViewHolder> {

    public DayTimeAdapter( @Nullable List<OrderDate> data) {
        super(R.layout.item_service_time_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderDate item) {

        TextView tvTime = helper.getView(R.id.tv_time);
        tvTime.setText(item.getDate());
        long curTime = System.currentTimeMillis()+30*1000*60;
        long itemTime = DateUtil.dateToStamp(item.getYear()+" "+item.getDate()+":00");
        if (item.getDate_count()==1){
            tvTime.setTextColor(mContext.getResources().getColor(R.color.grayc8));
            tvTime.setText(item.getDate()+"\n"+"预约已满");
            tvTime.setBackgroundResource(R.drawable.shap_line_square_layout);
        }else if(itemTime<curTime){
            tvTime.setTextColor(mContext.getResources().getColor(R.color.grayc8));

            tvTime.setBackgroundResource(R.drawable.shap_line_square_layout);
        }else {
            if (item.isChose()){
                tvTime.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
                tvTime.setBackgroundResource(R.drawable.shap_line_round_primary_color_zhi);
            }else {
                tvTime.setTextColor(mContext.getResources().getColor(R.color.black));
                tvTime.setBackgroundResource(R.drawable.shap_line_square_layout);
            }

        }
    }


}
